package geektime.spring.springbucks.waiter;

import geektime.spring.springbucks.waiter.message.Message;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.integration.support.MessageBuilder;

public class AnnotationStarterRefreshListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
//        ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
//         注入
//        Message message = applicationContext.getBean(Message.class);
//        boolean hello = message.message().send(MessageBuilder.withPayload("hello").build());
//        System.out.println("发送消息结果："+hello);
    }
}
